package com.jtspgl.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jtspgl.service.UserService;

/**
 * 
 * UserController  
 * <p>测试接口类。</p> 
 * @author sunChangXing
 * @version v1.0.0
 * <p><B>last update </B> by sunChangXing @ 2018年3月31日</p>
 * @since v1.0.0
 */
@Controller
@RequestMapping("/user")
public class UserController {
	private static final Logger logger = LogManager.getLogger(UserController.class);
	
	@Autowired
	private UserService userService;
	
	/**
	 * 
	 * 一个测试方法用来测试是否可以操作数据库。
	 * <p>打开浏览器  http://127.0.0.1:8080/jtspgl/user/getUserInfo?id=1  就是你这个方法得作用了</p>
	 * @param id 用户id
	 * @return
	 */
	@ResponseBody
	@RequestMapping("getUserInfo")
	public Map<String, Object> getUserInfo(@RequestParam(value="id", required=false) Integer id){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = this.userService.getUserInfo(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return resultMap;
		
	}
}
